package com.txunda.zhuohired.aty.user.my;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.TextView;

import com.ants.theantsgo.view.pulltorefresh.PullToRefreshScrollView;
import com.lidroid.xutils.view.annotation.ViewInject;
import com.txunda.zhuohired.R;
import com.txunda.zhuohired.base.BaseAty;
import com.txunda.zhuohired.fgt.user.my.CareerProgressFgt;

import java.util.ArrayList;
import java.util.List;

/**
 * 创建人： Txd_Cjh
 * 创建时间： 2018/3/9 10:24
 * 功能描述：求职进展
 * 联系方式：jiahuanchen@126.com
 */

public class CareerProgressAty extends BaseAty {
    /**
     * 标题
     */
    @ViewInject(R.id.tv_layout_white_center)
    private TextView tv_layout_white_center;
    /**
     * 说明
     */
    @ViewInject(R.id.tv_layout_white_right)
    private TextView tv_layout_white_right;
    /**
     * tabLayout
     */
    @ViewInject(R.id.tl_career_progress)
    private TabLayout tl_career_progress;
    /**
     * viewPager
     */
    @ViewInject(R.id.vp_career_progress)
    private ViewPager vp_career_progress;

    private ArrayList<Fragment> mFragments;
    private MyPagerAdapter myPagerAdapter;

    private List<String> tittleList;
    private String[] tittleStr = {"全部", "申请成功", "拒绝面试", "面试邀请"};

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        showStatusBar(R.id.layout_white_head);
        tv_layout_white_center.setText("求职进展");
        tv_layout_white_right.setVisibility(View.VISIBLE);
        tv_layout_white_right.setText("说明");
    }

    @Override
    protected int getLayoutResId() {
        return R.layout.aty_career_progress;
    }

    @Override
    protected void initialized() {
        tittleList = new ArrayList();
        mFragments = new ArrayList<>();
        myPagerAdapter = new MyPagerAdapter(getSupportFragmentManager());
        for (int i = 0; i < tittleStr.length; i++) {
            tittleList.add(tittleStr[i]);
        }
        mFragments.add(CareerProgressFgt.getFgt(1));
        mFragments.add(CareerProgressFgt.getFgt(2));
        mFragments.add(CareerProgressFgt.getFgt(3));
        mFragments.add(CareerProgressFgt.getFgt(4));
    }

    @Override
    protected void requestData() {
        vp_career_progress.setAdapter(myPagerAdapter);
        tl_career_progress.setupWithViewPager(vp_career_progress);
    }

    private class MyPagerAdapter extends FragmentPagerAdapter {
        public MyPagerAdapter(FragmentManager fm) {
            super(fm);
        }


        @Override
        public int getCount() {
            return mFragments.size();
        }

        @Override
        public CharSequence getPageTitle(int position) {
            return tittleList.get(position);
        }

        @Override
        public Fragment getItem(int position) {
            return mFragments.get(position);
        }
    }
}
